using System.Collections.Generic;
using System.Linq;

namespace Mbl.ParameterizedTest.FluentCollectionBuilding.Expectors.EnumerableExpectations
{
    public class ContainsAnyExpectation<TElement> : PredicateExpectation<IEnumerable<TElement>>        
    {
        private readonly TElement[] _expected;

        public ContainsAnyExpectation(TElement[] expectedElements)
            : base(actual => expectedElements.Any(actual.Contains))
        {
            _expected = expectedElements;
        }

        protected override string GetErrorMessage(IEnumerable<TElement> actual)
        {
            return $"Expected '{CollectionFormatter.Format(actual)}' to contain at least one of '{CollectionFormatter.Format(_expected)}'";
        }
    }
}